<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <title> 测试页面 </title>
  <meta charset="utf-8">
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Cache-control" content="no-cache;max-age=0">
  <meta http-equiv="expires" content="0">
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
  <script>
    //设置根节点的font-size属性以适用rem布局
    function setHtmlFontSize() {
      var deviceWidth = document.documentElement.clientWidth;
      document.documentElement.style.fontSize = deviceWidth / 7.5 + 'px';
    }
    setHtmlFontSize();
    //横竖屏切换事件
    window.addEventListener("resize", function () { setHtmlFontSize() }, false);
  </script>
  <style>
    body {
      width: 7.5rem;
      margin: 0 auto;
      padding: 0.6rem 0 1.2rem;
    }

    h1 {
      font-size: 0.3rem;
    }
  </style>
</head>

<body>
  <h1>你好，世界！</h1>
</body>

</html>